﻿using System;
using System.Data;
using System.Configuration;
using System.Collections;
using System.Web;
using System.Web.Security;
using System.Web.UI;
using System.Web.UI.WebControls;
using System.Web.UI.WebControls.WebParts;
using System.Web.UI.HtmlControls;
using HZ.MBSM.DBUtility;

public partial class Manage_ProsecuteAnswerUpdate : System.Web.UI.Page
{
    public string strName1, strContent1;
    public string Id;
    protected void Page_Load(object sender, EventArgs e)
    {
        string strName, strContent;
        System.Collections.Generic.List<HZ.MBSM.DAL.AccountType> _AccountType = new System.Collections.Generic.List<HZ.MBSM.DAL.AccountType>();
        _AccountType.Add(HZ.MBSM.DAL.AccountType.enumAdmin);
        _AccountType.Add(HZ.MBSM.DAL.AccountType.enumAttorney);
        _AccountType.Add(HZ.MBSM.DAL.AccountType.enumSupervise);
        if (HZ.MBSM.BLL.Login.CheckAssert(_AccountType))
        {
            if (!IsPostBack)
            {
                string strSql;
                if (Request.QueryString["Id"] != null)
                    Id = SysFun.IsSQL(Request.QueryString["Id"].ToString());
                else
                    return;
                strSql = "select * from ProsecuteAnswer where Id=" + Id;
                Db DbInfo = new Db();
                System.Data.IDataReader dr;
                dr = DbInfo.DataReader(strSql);
                if (dr.Read())
                {
                    //txtTitle.Text = dr["Title"].ToString();
                    //txtContent.Text = dr["Content"].ToString();                   
                    txtAddDate.Text = Convert.ToDateTime(dr["AddDate"].ToString()).ToShortDateString();
                    txtAddDate.Visible = false;
                    txtId.Text = dr["Id"].ToString();
                    txtId.Visible = false;
                    strName1 = dr["Title"].ToString();
                    strContent1 = dr["Content"].ToString();

                }
                dr.Close();
                dr.Dispose();
                DbInfo.Close();
            }
            strName = SysFun.ToTrim(Request.Form["txtName"]);
            strContent = SysFun.ToTrim(Request.Form["txtContentHtml"]);
            if (strName != "" && strContent != "")
            {
                Db db1 = new Db();
                Grove.ORM.ObjectOperator oo = db1.GetObjectOperator();
                HZ.MBSM.Model.ProsecuteAnswer ProsecuteAnswer = new HZ.MBSM.Model.ProsecuteAnswer();
                ProsecuteAnswer.Id = Convert.ToInt64(txtId.Text);
                ProsecuteAnswer.Title = strName;
                //dr["Content"].ToString().Replace("\r\n","<br>")
                ProsecuteAnswer.Content = strContent.Replace("\r\n", "");
                ProsecuteAnswer.AddDate = Convert.ToDateTime(txtAddDate.Text);
                oo.Update(ProsecuteAnswer);
                oo.Dispose();
                db1.Close();
                Response.Write("<script>alert('保存成功！！！');</script>");
                HZ.MBSM.Model.Account _Account = (HZ.MBSM.Model.Account)Session["Account"];
                HZ.MBSM.BLL.LogManage.RecordLoginDetail(_Account.AccountName, Request.UserHostAddress, "更新", "ProsecuteAnswer", ProsecuteAnswer.Title + "|" + ProsecuteAnswer.Content + "|" + ProsecuteAnswer.AddDate, "../Magage/ProsecuteAnswerUpdate.aspx");

                Response.Write("<script>window.opener.location.reload();window.close();</script>");
            }
        }
    }
}
